package com.icss.session.controller;

import com.icss.feign.UserService;
import com.icss.feign.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/* session控制器*/
@RestController
@RequestMapping(value = "session")
public class SessionController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = "query", method = RequestMethod.GET)
    public Integer querySession(@RequestParam("userId") int userId) {
        if(userId <= 0){
            return 0;
        }
        User user = userService.querySession(userId);
        if(user == null || user.getUser_id() <= 0){
            return 0;
        }
        return user.getUser_state();
    }


}


